﻿using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SXFramWork.Core;
using SXFramWork.Model;
using SXFramWork.Service;

namespace SXFramWork.API.Controllers.Admin
{
    /// <summary>
    /// 任务分组管理
    /// </summary>
    public class SysJobGroupController : WebController
    {
        private readonly ISysJobGroupService _service;
        public SysJobGroupController(ISysJobGroupService sysJobGroupService)
        {
            _service = sysJobGroupService;
        }
        /// <summary>
        /// 任务分组
        /// </summary>
        /// <param model=""></param>
        /// <returns></returns>
        [Menu("任务分组")]
        [HttpGet]
        [AllowAnonymous]
        public async Task<IApiResult> List([FromQuery]JobGroupQueryModel model )
        {
            return await _service.Query(model);
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [Power("添加")]
        [HttpPost]
        [AllowAnonymous]
        public async Task<IApiResult> Add([FromBody]JobGroupAddModel model)
        {
            return await _service.Add(model);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPost]
        [Power("删除")]
        [AllowAnonymous]
        [Log]
        public async Task<IApiResult> Delete([FromBody]string ids)
        {
            return await _service.Delete(ids);
        }
    }
}